train_cost=30,25,40,60
car_cost=25,40,45,50
plane_cost=40,20,50,45
costs=train_cost,car_cost,plane_cost

def unit_cost(route):
    n=len(route)
    basic=0
    for i in range(n):
        basic+=costs[eval(route[i])][i]
    extra=route.count('01')*5\
        +route.count('02')*12\
        +route.count('10')*8\
        +route.count('12')*10\
        +route.count('20')*15\
        +route.count('21')*10
    return basic+extra

routes=[]
def combine(n,route):
    if n == 0:
        routes.append(route)
    else:
        for i in range(3):
            combine(n-1,route+str(i))
    return routes

routes=combine(4,'')
unit_costs=[]
for route in routes:
    unit_costs.append(unit_cost(route))
lowest_cost=min(unit_costs)
choices=len(routes)
for i in range(choices):
    if unit_costs[i] == lowest_cost:
        print(f'Route: {routes[i]}')
print(f'Cost: {lowest_cost*20}')
